<template>
  <div class="list-table">
    <el-form ref="queryForm" :model="queryParams" :inline="true" @submit.native.prevent>
      <el-form-item :label="$t('名称')" prop="keyWord">
        <el-input
          v-model="queryParams.keyWord"
          :placeholder="$t('名称')"
          clearable
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item :label="$t('唯一标识')" prop="code">
        <el-input
          v-model="queryParams.code"
          :placeholder="$t('唯一标识')"
          clearable
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item :label="$t('唯一标识别名')" prop="code">
        <el-input
          v-model="queryParams.codeFlag"
          :placeholder="$t('唯一标识别名')"
          clearable
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item :label="$t('创建人')" prop="createBy">
        <UserSelect
          v-model="queryParams.createBy"
          :placeholder="this.$t('创建人')"
          clearable
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item :label="$t('最后更新人')" prop="updateBy">
        <UserSelect
          v-model="queryParams.updateBy"
          :placeholder="this.$t('最后更新人')"
          clearable
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item :label="$t('发布状态')" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择">
          <el-option
            v-for="item in statusOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="queryHandle">{{ $t('搜索') }}</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          v-hasPermi="['system:word:edit']"
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="addHandle"
        >{{ $t('新增') }}</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          v-hasPermi="['system:word:edit']"
          type="success"
          icon="el-icon-video-play"
          size="mini"
          @click="checkAllKey"
        >{{ $t('测试全部指标') }}</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          v-hasPermi="['system:word:view']"
          type="info"
          icon="el-icon-video-tickets"
          size="mini"
          @click="viewCheckList"
        >{{ $t('检测日志') }}</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          v-hasPermi="['system:word:edit']"
          type="success"
          icon="el-icon-refresh"
          size="mini"
          @click="syncDataSourceDataHandle"
        >{{ $t('同步数据源') }}</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-setting"
          size="mini"
          @click="dataSourceList"
        >{{ $t('数据源') }}</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-s-data"
          size="mini"
          @click="keyRelationshipChartHandle"
        >{{ $t('关系树') }}</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="wordOnlineKeyWordList" border :default-expand-all="false" row-key="id" :tree-props="{children: 'children', hasChildren: 'hasChildren'}">>
      <el-table-column :label="$t('名称')" prop="keyWord" show-overflow-tooltip min-width="200">
        <template slot-scope="scope">
          <i v-show="scope.row.type === 'folder'" class="el-icon-fold" style="margin: -1px 0px;width: 17px;height: 17px;" />
          <i v-show="scope.row.type === 'key_word_tree' || scope.row.type === 'key_word'" class="el-icon-text-png" style="margin: 0px 0px 4px;width: 15px;height: 15px;" />
          {{ scope.row.keyWord }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('标识')" prop="code" align="center" show-overflow-tooltip min-width="140" />
      <el-table-column :label="$t('类型')" align="center" prop="type" :formatter="formatTypeColumn" show-overflow-tooltip min-width="100" />
      <el-table-column :label="$t('数据类型')" align="center" prop="dataType" :formatter="formatDateTypeColumn" min-width="100" />
      <el-table-column :label="$t('引用情况')" align="center" prop="quoteNum" show-overflow-tooltip min-width="75">
        <template slot-scope="scope">
          <span v-if="scope.row.type ==='folder'" />
          <span v-else>
            <span v-if="scope.row.quoteNum !== 0" class="link-type" @click="viewQuoteList(scope.row, 'quote')">{{ scope.row.quoteNum }}</span>
            <span v-else>0</span>
          </span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('被引用情况')" align="center" prop="quotedNum" show-overflow-tooltip min-width="90">
        <template slot-scope="scope">
          <span v-if="scope.row.type ==='folder'" />
          <span v-else>
            <span v-if="scope.row.quotedNum !== 0" class="link-type" @click="viewQuoteList(scope.row, 'quoted')">{{ scope.row.quotedNum }}</span>
            <span v-else>0</span>
          </span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('引用物理表数量')" align="center" prop="quoteTableNum" show-overflow-tooltip min-width="90">
        <template slot-scope="scope">
          <span v-if="scope.row.type ==='folder'" />
          <span v-else>
            <span v-if="scope.row.quoteTableNum !== 0" class="link-type" @click="viewQuoteTableList(scope.row)">{{ scope.row.quoteTableNum }}</span>
            <span v-else>0</span>
          </span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('发布状态')" align="center" prop="notPushNum" show-overflow-tooltip min-width="75">
        <template slot-scope="scope">
          <span v-if="scope.row.type ==='folder'" />
          <span v-else>
            <span>{{ formatStatus(scope.row.notPushNum) }} </span>
          </span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('创建人')" align="center" prop="createBy.nickName" show-overflow-tooltip min-width="100" />
      <el-table-column :label="$t('创建时间')" align="center" prop="createTime" show-overflow-tooltip min-width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('最后更新人')" align="center" prop="updateBy.nickName" show-overflow-tooltip min-width="100" />
      <el-table-column :label="$t('最后更新时间')" align="center" prop="updateTime" show-overflow-tooltip min-width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width" min-width="250">
        <template slot-scope="scope">
          <el-button
            v-if="scope.row.type !== 'folder'"
            v-hasPermi="['system:word:view']"
            size="small"
            type="text"
            icon="el-icon-view"
            @click="previewHandle(scope.row)"
          >{{ $t('预览') }}</el-button>
          <el-button
            v-hasPermi="['system:word:edit']"
            size="small"
            type="text"
            icon="el-icon-edit"
            @click="updateHandle(scope.row)"
          >{{ $t('修改') }}</el-button>
          <el-button
            v-if="!isBuiltin"
            v-hasPermi="['system:word:remove']"
            size="small"
            type="text"
            icon="el-icon-delete"
            @click="deleteHandle(scope.row)"
          >{{ $t('删除') }}</el-button>
          <!-- <el-button
            size="small"
            type="text"
            icon="el-icon-delete"
            @click="echartsOpen = true"
          >{{ $t("echart") }}</el-button> -->
          <el-dropdown v-if="scope.row.type !== 'folder'" trigger="click">
            <span class="el-dropdown-link" style="color: #0075BB; font-size: 12px;">
              <i class="el-icon-arrow-down el-icon--right" /> 更多操作
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>
                <el-button
                  v-if="scope.row.type !== 'folder' && scope.row.notPushNum > 0"
                  v-hasPermi="['system:word:edit']"
                  size="small"
                  type="text"
                  icon="el-icon-check"
                  @click="publishHandle(scope.row)"
                >{{ $t('发布') }}</el-button>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-button
                  v-if="scope.row.type !== 'folder'"
                  size="small"
                  type="text"
                  icon="el-icon-s-operation"
                  @click="subKeyList(scope.row)"
                >{{ $t('关联指标') }}</el-button>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-button
                  v-if="scope.row.type !== 'folder'"
                  v-hasPermi="['system:word:view']"
                  size="small"
                  type="text"
                  icon="el-icon-document-copy"
                  @click="viewKeyHistoryVersion(scope.row)"
                >{{ $t('版本') }}</el-button>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-button
                  v-if="scope.row.type !== 'folder'"
                  v-hasPermi="['system:word:view']"
                  size="small"
                  type="text"
                  icon="el-icon-s-promotion"
                  @click="releaseHandle(scope.row)"
                >{{ $t('发布菜单') }}</el-button>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-button
                  v-if="scope.row.type !== 'folder'"
                  v-hasPermi="['system:word:view']"
                  size="small"
                  type="text"
                  icon="el-icon-s-marketing"
                  @click="keyTreeHandle(scope.row)"
                >{{ $t('被引用关系树') }}</el-button>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-button
                  v-if="scope.row.type !== 'folder'"
                  v-hasPermi="['system:word:view']"
                  size="small"
                  type="text"
                  icon="el-icon-s-marketing"
                  @click="quotekeyTreeHandle(scope.row)"
                >{{ $t('引用关系树') }}</el-button>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>

    <!-- 添加或修改关键字数据集对话框 -->
    <el-dialog :title="$t(title)" :visible.sync="formOpen" :close-on-click-modal="false" :lock-scroll="false" class="form-dialog" append-to-body>
      <wordOnlineKeyWordForm ref="wordOnlineKeyWordForm" />
    </el-dialog>
    <el-dialog :title="$t(quoteTitle)" :visible.sync="quoteOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class="" width="80%" append-to-body>
      <wordOnlineKeyWordQuoteList ref="wordOnlineKeyWordQuoteList" />
    </el-dialog>
    <el-dialog :title="$t('预览数据')" :visible.sync="previewOpen" width="80%" :close-on-click-modal="false" :lock-scroll="false" custom-class="" append-to-body>
      <wordOnlineKeyWordParamsForm ref="wordOnlineKeyWordParamsForm" />
    </el-dialog>
    <el-dialog :title="$t('指标历史版本')" :visible.sync="historyVersionOpen" width="80%" :close-on-click-modal="false" :lock-scroll="false" custom-class="" append-to-body>
      <wordOnlineKeyWordVersionList ref="wordOnlineKeyWordVersionList" />
    </el-dialog>
    <el-dialog :title="$t('指标检测日志')" :visible.sync="checkOpen" width="80%" :close-on-click-modal="false" :lock-scroll="false" custom-class="" append-to-body>
      <wordOnlineKeyWordCheckRecordList ref="wordOnlineKeyWordCheckRecordList" />
    </el-dialog>
    <el-dialog :title="$t('引用物理表情况')" :visible.sync="quoteTableOpen" width="20%" :close-on-click-modal="false" :lock-scroll="false" custom-class="" append-to-body>
      <wordOnlineKeyQuoteTableForm ref="wordOnlineKeyQuoteTableForm" />
    </el-dialog>
    <el-dialog :title="$t('数据源')" :visible.sync="dataSourceOpen" width="80%" :close-on-click-modal="false" :lock-scroll="false" custom-class="" append-to-body>
      <wordOnlineKeyDataSourceList ref="wordOnlineKeyDataSourceList" />
    </el-dialog>
    <el-dialog :title="$t('关联指标')" :visible.sync="subKeyOpen" width="80%" :close-on-click-modal="false" :lock-scroll="false" custom-class="" append-to-body>
      <wordOnlineKeyWordSubList ref="wordOnlineKeyWordSubList" />
    </el-dialog>
    <el-dialog :title="$t('同步指标')" :visible.sync="syncRecordOpen" width="80%" :close-on-click-modal="false" :lock-scroll="false" custom-class="" append-to-body>
      <wordOnlineKeySyncRecordList ref="wordOnlineKeySyncRecordList" />
    </el-dialog>
    <el-dialog v-el-drag-dialog :title="$t('菜单')" :visible.sync="menuFormOpen" width="70%" class="dataForm" :close-on-click-modal="false" :lock-scroll="false">
      <div style="height: 450px;overflow: auto;padding: 20px;margin: -20px;">
        <el-form ref="menuForm" :model="menuForm" :rules="menuRules" label-width="80px">
          <el-row>
            <el-col :span="12">
              <el-form-item :label="$t('菜单图标')">
                <el-popover placement="bottom-start" width="460" trigger="click" @show="$refs['iconSelect'].reset()">
                  <IconSelect ref="iconSelect" @selected="selected" />
                  <el-input slot="reference" v-model="menuForm.icon" :placeholder="$t('菜单图标')" readonly>
                    <svg-icon v-if="menuForm.icon" slot="prefix" :icon-class="menuForm.icon" class="el-input__icon" style="height: 32px;width: 16px;" />
                    <i v-else slot="prefix" class="el-icon-search el-input__icon" />
                  </el-input>
                </el-popover>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :label="$t('菜单标识')" prop="menuKey">
                <el-input v-model="menuForm.menuKey" :placeholder="$t('菜单标识')" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :label="$t('菜单名称')" prop="menuName">
                <el-input v-model="menuForm.menuName" :placeholder="$t('菜单名称')" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :label="$t('显示排序')" prop="orderNum">
                <el-input-number v-model="menuForm.orderNum" controls-position="right" :min="0" :max="9999" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item :label="$t('组件路径')" prop="component">
                <el-input v-model="menuForm.component" disabled :placeholder="$t('组件路径')" />
              </el-form-item>
            </el-col>
            <!--  菜单权限 -->
          </el-row>
        </el-form>
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">{{ $t("取消") }}</el-button>
        <el-button type="primary" @click="submitForm">{{ $t("确定") }}</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="$t('指标树图')" :visible.sync="echartsOpen" :close-on-click-modal="false" :lock-scroll="false" class="form-dialog" append-to-body>
      <treeChart ref="treeChart" :chart-data="chartData" height="100%" />
    </el-dialog>
    <el-dialog :title="$t('指标关系图')" :visible.sync="rsChartOpen" width="90%" :close-on-click-modal="false" :lock-scroll="false" class="form-dialog" append-to-body>
      <keyRelationshipChart ref="keyRelationshipChart" :chart-data="rsChartData" height="100%" />
    </el-dialog>
  </div>
</template>

<script>
import { delWordOnlineKeyWord, exportWordOnlineKeyWord, listWordOnlineKeyWord, operateInfo, checkAllKey, keyQuoteTree, quotekeyTree, getKeyRelationShipChartData, syncDataSourceData } from '@/api/system/word/keyword/wordOnlineKeyWord'
import wordOnlineKeyWordForm from './wordOnlineKeyWordForm.vue'
import wordOnlineKeyWordQuoteList from './wordOnlineKeyWordQuoteList.vue'
import wordOnlineKeyQuoteTableForm from '../../wordOnlineKeyQuoteTableForm.vue'
import wordOnlineKeyWordParamsForm from './wordOnlineKeyWordParamsForm.vue'
import wordOnlineKeyWordVersionList from '../../wordOnlineKeyWordVersionList.vue'
import wordOnlineKeyWordCheckRecordList from '../../wordOnlineKeyWordCheckRecordList.vue'
import wordOnlineKeyWordSubList from '../../wordOnlineKeyWordSubList.vue'
import wordOnlineKeyDataSourceList from '../../wordOnlineKeyDataSourceList.vue'
import wordOnlineKeySyncRecordList from '../../wordOnlineKeySyncRecordList.vue'
import IconSelect from '@/components/IconSelect'
import { saveMenu } from '@/api/system/menu'
import treeChart from '@/views/chart/treeChart.vue'
import keyRelationshipChart from '@/views/chart/keyRelationshipChart.vue'
export default {
  components: {
    treeChart,
    keyRelationshipChart,
    wordOnlineKeyWordForm,
    /**
     * 引用情况页面
     */
    wordOnlineKeyWordQuoteList,
    /**
     * 预览页面
     */
    wordOnlineKeyWordParamsForm,
    /**
     * 历史版本页面
     */
    wordOnlineKeyWordVersionList,
    /**
     * 检测日志
     */
    wordOnlineKeyWordCheckRecordList,
    wordOnlineKeyWordSubList,
    IconSelect,
    /**
     * 数据源页面
     */
    wordOnlineKeyDataSourceList,
    /**
     * 同步指标页面
     */
    wordOnlineKeySyncRecordList,
    wordOnlineKeyQuoteTableForm
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 关键字数据集表格数据
      wordOnlineKeyWordList: [],
      // 弹出层标题
      title: '关键字数据集',
      // 是否显示弹出层
      formOpen: false,
      quoteOpen: false,
      previewOpen: false,
      subKeyOpen: false,
      historyVersionOpen: false,
      quoteTableOpen: false,
      syncRecordOpen: false,
      dataSourceOpen: false,
      checkOpen: false,
      rsChartOpen: false,
      rsChartData: {},
      // 查询参数
      queryParams: {
        keyWord: undefined,
        templateType: undefined,
        sqlScript: undefined,
        createBy: undefined,
        updateBy: undefined
      },
      statusOptions: [{
        value: 'N',
        label: '未发布'
      }, {
        value: 'Y',
        label: '已发布'
      }],
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      // 类型
      typeFolderOrKeyWOrdOptions: [],
      dateTypeOptions: [],
      isBuiltinData: 'N',
      quoteTitle: '引用情况',
      envInfo: process.env.NODE_ENV,
      // 菜单弹出框
      menuFormOpen: false,
       // 菜单
      menuForm: {},
      menuRules: {
        component: [{
          required: false,
          message: this.$t('必填信息'),
          trigger: 'blur'
        }],
        menuName: [{
          required: true,
          message: this.$t('必填信息'),
          trigger: 'blur'
        }],
        orderNum: [{
          required: true,
          message: this.$t('必填信息'),
          trigger: 'blur'
        }],
        name: [{
          required: true,
          message: this.$t('必填信息'),
          trigger: 'blur'
        }]
      },
      echartsOpen: false,
      chartData: []
    }
  },
  computed: {
    isBuiltin() {
      // 是否内置的数据
      return this.isBuiltinData === 'Y'
    }
  },
  created() {
    // 类型
    this.getDicts('key_word_directory_text').then((response) => {
      this.typeFolderOrKeyWOrdOptions = response.data
    })
    this.getDicts('key_data_type').then((response) => {
      this.dateTypeOptions = response.data
    })
    this.getList()
    // 获取是否内置数据的变量
    this.getIsBuiltinDataVariable()
  },
  methods: {
    /** 查询关键字数据集列表 */
    getList() {
      this.loading = true
      listWordOnlineKeyWord(this.queryParams).then(response => {
        this.wordOnlineKeyWordList = response.data
        this.loading = false
      })
    },
    formatTypeColumn(row) {
      return this.selectDictLabel(this.typeFolderOrKeyWOrdOptions, row.type)
    },
    formatDateTypeColumn(row) {
      return this.selectDictLabel(this.dateTypeOptions, row.dataType)
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        keyWord: undefined,
        busType: undefined,
        sqlScript: undefined,
        createBy: undefined,
        updateBy: undefined,
        createTime: undefined,
        updateTime: undefined,
        delFlag: undefined
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    queryHandle() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.queryHandle()
    },
    /** 新增按钮操作 */
    addHandle() {
      this.formOpen = true
      this.$nextTick(() => {
        this.$refs.wordOnlineKeyWordForm.init(null)
      })
    },
    /** 修改按钮操作 */
    updateHandle(row) {
      this.formOpen = true
      this.$nextTick(() => {
        // 调用form页面的 init 方法初始化数据
        this.$refs.wordOnlineKeyWordForm.init(row)
      })
    },
    viewKeyHistoryVersion(row) {
      this.historyVersionOpen = true
      this.$nextTick(() => {
        this.$refs.wordOnlineKeyWordVersionList.init(row)
      })
    },
    subKeyList(row) {
      this.subKeyOpen = true
      this.$nextTick(() => {
        this.$refs.wordOnlineKeyWordSubList.init(row)
      })
    },
    /** 删除按钮操作 */
    deleteHandle(row) {
      this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
        type: 'warning'
      }).then(function() {
        return delWordOnlineKeyWord(row.id)
      }).then(() => {
        this.getList()
        this.msgSuccess(this.$t('删除成功'))
      }).catch(function() {
      })
    },
    /** 导出按钮操作 */
    exportHandle() {
      const queryParams = this.queryParams
      this.$confirm(this.$t('是否确认导出数据项?'), this.$t('警告'), {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
        type: 'warning'
      }).then(function() {
        return exportWordOnlineKeyWord(queryParams)
      }).then(response => {
        this.download(response.msg)
      }).catch(function() {
      })
    },
    publishHandle(row) {
        /* this.$prompt('请输入推送秘钥', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          inputErrorMessage: '秘钥不能为空',
          inputValidator: (value) => {
            if (!value.trim()) {
              return '秘钥不能为空'
            }
            return true
          }
        }).then(({ value }) => {
          return operateInfo(row.id, value)
        }).then(() => {
            this.getList()
            this.msgSuccess(this.$t('发布成功'))
        }).catch(() => {
            this.loading = false
        }) */
        this.syncRecordOpen = true
        this.$nextTick(() => {
          this.$refs.wordOnlineKeySyncRecordList.init(row)
        })
    },
    unPublishHandle(row) {
      this.$confirm(this.$t('是否确认取消发布?'), this.$t('警告'), {
            confirmButtonText: this.$t('确定'),
            cancelButtonText: this.$t('取消'),
            type: 'warning'
        }).then(() => {
            return operateInfo(row.id, 'N')
        }).then(() => {
            this.getList()
            this.msgSuccess(this.$t('取消发布成功'))
        }).catch(() => {
            this.loading = false
        })
    },
    getIsBuiltinDataVariable() {
      this.getConfigKey('is_builtin_data').then(res => {
        if (res.msg && res.msg === 'Y') {
          this.isBuiltinData = res.msg
        }
      })
    },
    /**
     * 查看引用/被引用情况
     */
    viewQuoteList(row, type) {
      if (type === 'quote') {
        this.quoteTitle = '引用情况'
      } else {
        this.quoteTitle = '被引用情况'
      }
      this.quoteOpen = true
      this.$nextTick(() => {
        // 调用form页面的 init 方法初始化数据
        this.$refs.wordOnlineKeyWordQuoteList.init(row, type)
      })
    },
    /**
     * 查看引用物理表情况
     */
     viewQuoteTableList(row) {
      this.quoteTableOpen = true
      this.$nextTick(() => {
        this.$refs.wordOnlineKeyQuoteTableForm.init(row)
      })
    },
    previewHandle(row) {
      this.previewOpen = true
      this.$nextTick(() => {
        // 调用form页面的 init 方法初始化数据
        this.$refs.wordOnlineKeyWordParamsForm.init(row)
      })
    },
    viewCheckList() {
      this.checkOpen = true
      this.$nextTick(() => {
        this.$refs.wordOnlineKeyWordCheckRecordList.init()
      })
    },
    dataSourceList() {
      this.dataSourceOpen = true
      this.$nextTick(() => {
        this.$refs.wordOnlineKeyDataSourceList.getList()
      })
    },
    formatStatus(val) {
      if (val > 0) {
        return '未发布'
      } else {
        return '已发布'
      }
    },
    checkAllKey() {
      this.$confirm(this.$t('是否要检测全部指标?'), this.$t('提示'), {
            confirmButtonText: this.$t('确定'),
            cancelButtonText: this.$t('取消'),
            type: 'warning'
        }).then(() => {
            return checkAllKey()
        }).then(() => {
            this.msgSuccess(this.$t('正在检测，请稍后在检测记录中查看'))
        })
    },
    releaseHandle(row) {
      this.menuFormOpen = true
      this.menuForm = {
        menuId: undefined,
        menuKey: row.code + '_menu',
        parentId: '432beaaf18824679bcd2a0b2ad305936',
        menuName: row.keyWord,
        icon: undefined,
        menuType: 'C',
        orderNum: 10,
        isFrame: '1',
        visible: '0',
        permissionList: []

      }
      this.menuForm.component = 'system/word/report/wordKeyReport?id=' + row.id
    },
    // 取消按钮
    cancel() {
      this.menuFormOpen = false
      this.menuForm = {}
    },
    // 选择图标
    selected(name) {
      this.menuForm.icon = name
    },
    keyTreeHandle(row) {
      this.echartsOpen = true
      const params = {
        queryKeyId: row.id
      }
      keyQuoteTree(params).then(response => {
        this.chartData = response.data
      })
    },
    quotekeyTreeHandle(row) {
      this.echartsOpen = true
      const params = {
        queryKeyId: row.id
      }
      quotekeyTree(params).then(response => {
        this.chartData = response.data
      })
    },
    keyRelationshipChartHandle() {
      this.rsChartOpen = true
      const params = {
      }
      getKeyRelationShipChartData(params).then(response => {
        this.rsChartData = response.data
      })
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs['menuForm'].validate(valid => {
        if (valid) {
          this.menuForm.scene = '0'
          saveMenu(this.menuForm).then(response => {
            if (response.code === 200) {
              this.msgSuccess(this.$t('修改成功'))
              this.menuFormOpen = false
            } else {
              this.msgError(response.msg)
            }
          })
        }
      })
    },
    syncDataSourceDataHandle() {
      this.$confirm(this.$t('是否要同步多数源的指标数据?'), this.$t('提示'), {
            confirmButtonText: this.$t('确定'),
            cancelButtonText: this.$t('取消'),
            type: 'warning'
        }).then(() => {
          this.loading = true
            return syncDataSourceData()
        }).then(() => {
          this.loading = false
            this.msgSuccess(this.$t('同步成功'))
        })
        this.loading = false
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
